class Animal:
    def speak(self):
        raise NotImplementedError("子类必须实现该方法")


class Dog(Animal):
    def speak(self):
        return "汪汪汪"


class Cat(Animal):
    def speak(self):
        return "喵喵喵"


def perform_speak(animal):
    """根据传入的animal对象，调用对应的speak方法"""
    print(animal.speak())


# 使用
dog = Dog()
cat = Cat()
perform_speak(dog)  # 输出: 汪汪汪
perform_speak(cat)  # 输出: 喵喵喵
